import BaseController from '../../core/controllers/Base.controller';

@Inject('$log', '$scope', 'disclosureService', 'trainingService', 'meetingService', '$state')
class safeActivitiesController extends BaseController {
  constructor() {
    super();

    this.view = {
      currentShowTableIndex: -1,
      selectedItem: {},
    };

    this.resource = {
      activityList: [],
    };

    switch ($state.current.name) {
      case 'documentItemMgt.disclosures':
        this.view.type = 1;
        this.view.typeName = '技术交底';
        this.paginationService = disclosureService;
        break;
      case 'documentItemMgt.trainings':
        this.view.type = 2;
        this.view.typeName = '培训';
        this.paginationService = trainingService;
        break;
      case 'documentItemMgt.meetings':
        this.view.type = 3;
        this.view.typeName = '会议';
        this.paginationService = meetingService;
        break;
      case 'disclosures':
        this.view.type = 1;
        this.view.typeName = '技术交底';
        this.paginationService = disclosureService;
        break;
      case 'trainings':
        this.view.type = 2;
        this.view.typeName = '培训';
        this.paginationService = trainingService;
        break;
      case 'meetings':
        this.view.type = 3;
        this.view.typeName = '会议';
        this.paginationService = meetingService;
        break;
      default:
        break;
    }

    this.$setQueryCallback((res) => {
      this.resource.activityList = res.rows;
    });

    this.query();
  }

  query() {
    this.$paginationQuery();
  }

  reset() {
    this.mapParams = {};
  }

  showPreviewDocs(item, tableIndex) {
    this.view.currentShowTableIndex = tableIndex;
    this.view.selectedItem = item;
  }
}

export default safeActivitiesController;
